feat(cudf): Stream full-partition COUNT and peer-aware RANGE SUM - #2
Draft
sperlingxx wants to merge 5 commits into
Draft
feat(cudf): Stream full-partition COUNT and peer-aware RANGE SUM#2sperlingxx wants to merge 5 commits into
sperlingxx wants to merge 5 commits into
Conversation
Selective Build Plan
Selective build plan |
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Note
Migrated from sperlingxx/velox#56. Original author: @thirtiseven; original head:
thirtiseven/velox:agent/cudf-window-gapsatf4f5b06e599080b0d563a834b73c1a39295a9c0a.Summary
COUNTover sorted partition input.RANGE UNBOUNDED PRECEDING ... CURRENT ROWrunningSUM.OrderBypayload while continuing to reject MAP sort keys.Companion planner PR: NVIDIA/spark-gluten#50.
Root cause
The cuDF Window adapter supported streaming rank functions but did not have bounded cross-batch state for a result that is known only at a partition boundary, or for a RANGE result that is known only at a peer boundary. Full-partition COUNT was therefore rejected, and the multi-key default Spark RANGE frame was unsupported.
The Job 144 input also carries a MAP payload through its required
OrderBy. The spill schema check rejected MAP columns even when they were not sort keys.Design
Full-partition COUNT
The operator emits completed partitions as soon as the next partition boundary arrives. It retains only the active partition rows and a BIGINT row count. Active rows spill through the existing Parquet infrastructure above the configured memory bound, then replay through the normal
getOutput()backpressure path with the final count attached.Peer-aware RANGE SUM
The operator retains the active peer, the current partition's cumulative sum, and a valid-value count. It emits a completed peer when the next peer or partition arrives. The valid count preserves Spark null behavior for all-null prefixes.
The q3 libcudf dependency does not expose the newer multi-order-column grouped RANGE API. The implementation therefore uses libcudf sorted grouping and lower-bound primitives over all partition and order columns, including direction and null ordering, and repeats each peer-end running result across the peer. It does not implement host-side RANGE comparison semantics.
All persistent GPU state is allocated on the existing state stream with the configured async RMM resource. The implementation does not add MPP control state or query rewrites.
Supported scope
COUNT(non-null constant)with a full-partition ROWS frame and BIGINT result.SUM(field)withRANGE UNBOUNDED PRECEDING ... CURRENT ROW.The adapter continues to reject nullable-column counts, DISTINCT, bounded RANGE offsets, unvalidated decimal/ANSI overflow behavior, and incompatible mixed frames.
Validation
noMoreInput.CudfOrderBy -> CudfWindowpipelines for the original full-partition COUNT and default multi-key RANGE SUM.Additional observations
The full Job 144 query contains a later
ROW_NUMBERdeduplication whose order key is not unique. Order-independent output digests differ between repeated runs, and the same affected columns already differed in pre-feature runs that used the historical COUNT rewrite and explicit ROWS frame. Exact Window semantics are therefore asserted by the targeted reference tests; the full job validates native planning, row count, strict execution, and lifecycle.Two current q3 Job 8 reruns reached an existing global GPU-memory cliff while several rank pipelines fed concurrent hash-join build states. The device reached approximately 33.1 GiB before the next OrderBy allocation failed. The new COUNT and RANGE modes are both inactive for that rank-only plan, and the existing rank behavior is unchanged by this patch.